package com.hunttown.mes.rpc.domain.enums.workflow;

import java.util.HashMap;
import java.util.Map;

/**
 * 角色类型：1指定成员 2申请人 3复核人 4直属上级 5部门主管 6部门成员 7角色
 * created by wangjunfu on 2018/11/6
 */
public enum ApproverTypeEnum {
    FIX(1, "指定成员"),
    APPLY(2, "申请人"),
    REVIEW(3, "复核人"),
    DIRECT(4, "直属上级"),
    DEP(5, "部门主管"),
    FIXDEP(6, "部门成员"),
    ROLE(7, "角色");

    private final int key;
    private final String value;

    ApproverTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (ApproverTypeEnum temp : ApproverTypeEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (ApproverTypeEnum temp : ApproverTypeEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
